package com.woniuxy.lab.woniu_lab_boss.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.woniuxy.lab.woniu_lab_boss.common.Result;
import com.woniuxy.lab.woniu_lab_boss.model.Exper;
import com.woniuxy.lab.woniu_lab_boss.service.ExperService;
import com.woniuxy.lab.woniu_lab_boss.service.dto.ExperDto;
import com.woniuxy.lab.woniu_lab_boss.service.dto.HealthDto;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.constraints.Min;
import java.util.List;

/**
 * <p>
 * 实验表 前端控制器
 * </p>
 *
 * @author Silas
 * @since 2023-03-15
 */
@RestController
@RequestMapping("/exper")
@Slf4j
@Api(tags = "[D]实验环境相关接口")
public class ExperController {
    @Resource
    private ExperService experService;

    // 获取系统当前资源情况
    @ApiOperation("68 获取系统当前资源情况")
    @GetMapping("getHealth")
    public Result<HealthDto> getHealth() {
//        log.info("获取系统当前资源情况");
        HealthDto healthDto = experService.getHealth();
        return Result.success(200, "获取当前资源情况成功", healthDto);
    }

    /**
     * 查看进行中的实验
     *
     * @return
     */
    @ApiOperation("86 查看正在运行的实验")
    @GetMapping("/getExper")
    public Result<IPage<ExperDto>> getExper(
            @ApiParam(value = "第几页") @Min(value = 1, message = "页码必须大于1") Integer page,
            @ApiParam(value = "每页条数") @Min(value = 1, message = "每页展示数必须大于1")  Integer size) {
        log.info("查看所有运行中的实验{}{}",page,size);
        IPage<ExperDto> experDtoIPage = experService.getRunning(page,size);
        return Result.success(200, "查看运行中的实验成功", experDtoIPage);
    }
}

